package com.tedu.day04mybatis.mapper;

import com.tedu.day04mybatis.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface UserMapper {
    /* JDBC预编译SQL:
        INSERT INTO user(username,password,nickname,created,age)
        VALUES(?,?,?,?,?)
        在JDBC中占位符为? 每一个?分别对应user对象中各属性值
       而在mybatis中的占位符为#｛｝,在{}中指定user对象属性的名字即可
        INSERT INTO user(username,password,nickname,created,age)
        VALUES(#{username},#{password},#{nickname},#{created},#{age})
        {}中分别为User类中各属性
     */
    @Insert("INSERT INTO user(username,password,nickname,age,created) " +
            "VALUES(#{username},#{password},#{nickname},#{age},#{created})")
    int insert(User user);
    @Delete("DELETE FROM user WHERE id=#{id}")
    int delete(Integer id);



}
